package week_11;

import week_04.SingleList;

public class LinkListBubble {
    public static void sort(Comparable[] a) {
        SingleList<Integer> list = new SingleList<>();
        for (int l = 0; l < a.length; l++) {
            list.insert((Integer) a[l]);
        }
        for (int i = 0; i < a.length; i++) {
            for (int j = i + 1; j < a.length; j++) {
                if (greater(list.get(i), list.get(j))) {
                    list.perversion(i+1, j+1);
                }
            }
        }
        for (int l = 0; l < a.length; l++) {
            a[l] = list.get(l);
        }
    }

    public static boolean greater(Comparable v, Comparable w) {
        return v.compareTo(w) > 0;
    }
}
